package com.temi.iot.service.impl;

import com.temi.iot.common.constant.factory.PageFactory;
import com.temi.iot.common.constant.result.Page;
import com.temi.iot.common.constant.result.Result;
import com.temi.iot.entity.SysPermission;
import com.temi.iot.service.ISysPermissionService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author one
 * @since 2019-12-11
 */
@Service
public class SysPermissionServiceImpl implements ISysPermissionService {

    @Override
    public Result insertPermission(SysPermission sysPermission) {
        sysPermission.insert();
        return Result.SUCCESS;
    }

    @Override
    public Result updatePermission(SysPermission sysPermission) {
        sysPermission.updateById();
        return Result.SUCCESS;
    }

    @Override
    public Result deletePermission(Long id) {
        SysPermission.builder().build().deleteById(id);
        return Result.SUCCESS;
    }

    @Override
    public Result selectPermissionDetail(Long id) {
        SysPermission sysPermission = SysPermission.builder().build().selectById(id);
        return Result.success(sysPermission);
    }

    @Override
    public Page selectPermissionList() {
        return PageFactory.page(()->SysPermission.builder().build().selectAll());
    }
}
